import yfinance as yf
 
# 获取苹果公司股票历史数据
data = yf.download("AAPL", start="2022-01-01", end="2023-01-01")
 
print(data.head())  # 查看前 5 行数据


import tushare as ts
 
# 设置你的 Tushare Token
ts.set_token('your_token_here')
pro = ts.pro_api()
 
# 获取某只股票的日线数据
df = pro.daily(ts_code='000001.SZ', start_date='20220101', end_date='20230101')
 
print(df.head())


import talib
import pandas as pd
import yfinance as yf
 
# 获取股票数据
data = yf.download("AAPL", start="2022-01-01", end="2023-01-01")
 
# 计算 20 日均线
data['SMA_20'] = talib.SMA(data['Close'], timeperiod=20)
 
# 计算 RSI 指标
data['RSI'] = talib.RSI(data['Close'], timeperiod=14)
 
print(data[['Close', 'SMA_20', 'RSI']].tail())